package com.java.poc.app;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;

public class urlconnection {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
	        URL url = new URL("https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=0&companyName=&address1=24611+116th+Ave+SE&address2=temp1&city=KENT&state=WA&urbanCode=&postalCode=&zip=98030");
	        URLConnection conn = url.openConnection(Proxy.NO_PROXY);

	        conn.addRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");


	        //System.out.println("now to set cookie: " + cookie);

	        //conn.addRequestProperty("Cookie", cookie);






	        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	        String inputLine;

	        //extractCookie(conn);



	        //PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter("out.txt")));


	        StringBuilder sb = new StringBuilder();
	        System.out.println(in.toString());

	        while ((inputLine = in.readLine()) != null)
	        {
	            //file.println(inputLine);
	            sb.append(inputLine).append("\n");
	        }

	        in.close();


	        //file.close();



	        System.out.println(sb);

	    } catch (Exception e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
	    }

	}

}
